package com.sfx.other.Generics;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-09-09
 * Time: 8:22
 */
public class Pair<T, U> {
    private T first;
    private U second;

    public Pair() {
    }

    public Pair(T first, U second) {
        this.first = first;
        this.second = second;
    }

    public T getFirst() {
        return first;
    }

    public void setFirst(T first) {
        this.first = first;
    }

    public U getSecond() {
        return second;
    }

    public void setSecond(U second) {
        this.second = second;
    }

    public static <T> int indexOf(T[] arr, T elm) {
        for (int i = 0; i < arr.length; ++i) {
            if (arr[i].equals(elm)) {
                return i;
            }
        }
        return -1;
    }


    public static void main(String[] args) {
        Pair<Integer, String> pair = new Pair<>();
        indexOf(new Integer[]{1,2,3,4},5);
        indexOf(new String[]{"1","2","3","4"},5);
    }
}
